//#include<iostream>
//#include<vector>
//#include<algorithm>
//
//using namespace std;
//class Solution {
//public:
//    int maxProfit(vector<int>& prices) {
//        int n = prices.size();
//        vector<int> buy(n);
//        auto sell = buy;
//        vector<int> cnt;
//        buy[0] = -prices[0];
//        int num = 0;
//        for (int i = 1; i < n; i++)
//        {
//            if (sell[i - 1] + prices[i] > buy[i - 1])
//            {
//                cnt.push_back(prices[i] - num);
//            }
//            buy[i] = max(sell[i - 1] + prices[i], buy[i - 1]);
//            if (buy[i - 1] - prices[i] > sell[i - 1])
//            {
//                num = prices[i];
//            }
//            sell[i] = max(sell[i - 1], buy[i - 1] - prices[i]);
//        }
//        sort(cnt.begin(), cnt.end(), [](int i, int j)->bool {return i < j; });
//        int ret = cnt[0] + cnt[1];
//        return ret;
//    }
//};
//
////class Solution {
////public:
////    int minCost(vector<vector<int>>& costs) {
////        int n = costs.size();
////        vector<int> red(n+1);
////        auto blue = red;
////        auto green = red;
////        for (int i = 1; i <= n; i++)
////        {
////            red[i] = min(blue[i - 1], green[i - 1]) + costs[i - 1][0];
////            blue[i] = min(red[i - 1], green[i - 1]) + costs[i - 1][1];
////            green[i] = min(red[i - 1], blue[i - 1]) + costs[i - 1][2];
////        }
////        return min(min(red[n], blue[n]), green[n]);
////    }
////};